package com.jinandi.app.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jinandi.app.dao.AuthorityDao;
import com.jinandi.app.domain.Authorit;

@Service
public class AuthoritService extends BaseService{

	private AuthorityDao authorityDao;

	@Autowired
	public void setAuthorityDao(AuthorityDao authorityDao) {
		this.authorityDao = authorityDao;
	}
	
	/**
	 * <角色列表>
	 * @param params
	 * @param map
	 * @return
	 * @author CGC 
	 * 创建日期:2013-5-9 下午1:43:26
	 */
	@Transactional
	public Page<Authorit> findAuthoritLisr(Map<String,Object> params,Map<String ,String> map) {
		Page<Authorit> page= authorityDao.findAll(new Authorit().getSpecification(params), getPageRequest(map));
		return page;
	}

	/**
	 * <修改，新增角色>
	 * @param authorit
	 * @author CGC 
	 * 创建日期:2013-5-9 下午1:43:52
	 */
	@Transactional
	public void saveAuthorit(Authorit authorit) {
		authorityDao.save(authorit);

	}
	
	/**
	 * <根据ID查询角色 >
	 * @param id
	 * @return
	 * @author CGC 
	 * 创建日期:2013-5-9 下午1:44:11
	 */
	@Transactional(readOnly = true)
	public Authorit findAuthoritById(Long id) {
		return authorityDao.findAuthoritById(id);
	}

	/**
	 * <根据ID删除角色>
	 * @param id
	 * @author CGC 
	 * 创建日期:2013-5-9 下午1:44:28
	 */
	@Transactional
	public void deleteAuthoritById(Long id) {
		authorityDao.deleteAuthoritById(id);
		
	}

	/**
	 * <角色列表，出select用的>
	 * @return
	 * @author CGC 
	 * 创建日期:2013-5-9 下午1:44:59
	 */
	public List<Object[]> getAuthorit() {
		return authorityDao.getAuthorit();
	}
	
}
